import { Model } from 'pinia-orm';
import { Attr, Str, Uid, Num, Bool, HasOne, HasMany, BelongsTo, HasManyBy, BelongsToMany, MorphOne,
  MorphTo, MorphMany, MorphToMany, OnDelete
  } from 'pinia-orm/decorators';
import { useAxiosRepo } from '@pinia-orm/axios';
import { useAppConfig } from '@vben/hooks';
import type { MinishopSpu, MinishopSpuResponse } from '../../views/uctoo/minishop_spu/types.js';
//#region Human-Code Preservation

//#endregion Human-Code Preservation

const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);

export class uctoo_minishop_spu extends Model {
  static override entity = 'uctoo_minishop_spu'

@Uid() declare id: string 
@Str('') declare out_product_id: string | null
@Str('') declare title: string 
@Str('') declare subtitle: string | null
@Str('') declare headimg: string 
@Num(0) declare status: number 
@Num(0) declare edit_status: number 
@Num(0) declare min_price: number 
@Str('') declare cats: string | null
@Str('') declare attrs: string | null
@Uid() declare model: string | null
@Str('') declare dispatch_type: string | null
@Str('') declare express_info: string | null
@Str('') declare shopcat: string | null
@Str('') declare skus: string | null
@Num(0) declare sales_count: number 
@Num(0) declare weigh: number 
@Str('') declare template_id: string | null
@Str('') declare ext_json: string | null
@Str('') declare memo: string | null
@Str('') declare ext_attrs: string | null
@Uid() declare creator: string | null
@Attr('') declare start_at: string | null
@Attr('') declare end_at: string | null
@Attr('') declare meet_at: string | null
@Str('') declare address: string | null
@Num(0) declare latitude: number | null
@Num(0) declare longitude: number | null
@Attr('') declare created_at: string 
@Attr('') declare updated_at: string 
@Attr('') declare deleted_at: string | null
@Str('') declare desc_info: string | null
@Num(0) declare brand_id: number | null


  static override config = {
    axiosApi: {
        actions: {
            getuctooMinishopSpuList(page: number, pageSize: number, searchParams?: any){
                return useAxiosRepo(uctoo_minishop_spu).api().get(`/uctoo/minishop_spu/${pageSize}/${page}`, {
                  params: searchParams,
                  headers: { 'Content-Type': 'application/json;charset=utf-8',
                          'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                  },
                  baseURL: apiURL,
                  dataKey: 'minishopSpus'
                })
            },
            getuctooMinishopSpu(id: string){
              return useAxiosRepo(uctoo_minishop_spu).api().get(`/uctoo/minishop_spu/${id}`, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            adductooMinishopSpu(data: Partial<MinishopSpu>){
              return useAxiosRepo(uctoo_minishop_spu).api().post('/uctoo/minishop_spu/add', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            edituctooMinishopSpu(data: any){
              return useAxiosRepo(uctoo_minishop_spu).api().post('/uctoo/minishop_spu/edit', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            deleteuctooMinishopSpu(data: any){
              return useAxiosRepo(uctoo_minishop_spu).api().post('/uctoo/minishop_spu/del', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },

//#region Human-Code Preservation

//#endregion Human-Code Preservation
        } 
    }
  }
}
